package com.hbnu.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


@Component
@Aspect
public class LogRecord {
    @Pointcut("execution(* com.hbnu.service.CartService.*(..))")
        public void pointCut(){}
    @Before("pointCut()")
    public void beforeAddCart(){
        System.out.println("前置通知:在被增强方法之前执行");
    }
    @Around("pointCut()")
    public void aroundAddCart(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕通知:在被增强方法之前会执行");
        proceedingJoinPoint.proceed();
        System.out.println("环绕通知:在被增强方法之后会执行");
    }
}
